home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / geom.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.1 KB  |  80 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21.     /*
  22.      *  basic geometric primitive types
  23.      */
  24. typedef struct {
  25.     long x, y, z;
  26. } point;
  27.  
  28. typedef struct {
  29.     long x, y;
  30. } point2d;
  31.  
  32. typedef struct {
  33.     Coord x, y;
  34. } point2df;
  35.  
  36. typedef struct {
  37.     point2d orig;
  38.     point2d extent;
  39. } rectangle;
  40.  
  41. typedef struct {
  42.     point2df orig;
  43.     point2df extent;
  44. } rectanglef;
  45.  
  46. typedef struct {
  47.     point orig;
  48.     point extent;
  49. } cube;
  50.  
  51. typedef struct {
  52.     Coord x, y, z;
  53. } fpoint;
  54.  
  55. #ifndef TRUE
  56. #define TRUE 1
  57. #endif /* TRUE */
  58. #ifndef FALSE
  59. #define FALSE 0
  60. #endif /* FALSE */
  61.  
  62. #define abs(val) ((val) >= 0 ? (val) : -(val))
  63. #define sign(val) ((val) >= 0 ? 1 : -1)
  64. #define odd(val) ((val) & 01 ? TRUE : FALSE)
  65. #define min(val1,val2) ((val1) < (val2) ? (val1) : (val2))
  66. #define max(val1,val2) ((val1) > (val2) ? (val1) : (val2))
  67.  
  68. #define setrect(r,x1,y1,x2,y2) {(r)->orig.x = x1; \
  69.                 (r)->orig.y = y1; \
  70.                 (r)->extent.x = x2; \
  71.                 (r)->extent.y = y2; }
  72.  
  73. #define setpt2d(r,x1,y1) {(r)->x = x1; (r)->y = y1; }
  74.  
  75. #define PI 3.14159265358979323844
  76. #define DEG(x) ((float)x*(float)180/PI)
  77. #define RAD(x) ((float)x*PI/(float)180)
  78. #define HYPOT(a,b) sqrt(fabs((float)((a)*(a) + (b)*(b))))
  79.  
  80.